﻿using System;
using System.Data;
using System.Linq;
using Model;

namespace BLL
{
    public class ELMAH_Error_BLL
    {
        ExtendedDBModelContainer _db = new ExtendedDBModelContainer();

        public IQueryable<ELMAH_Error> Get()
        {
            return _db.ELMAH_Error.OrderByDescending(a => a.TimeUtc);
        }

        public void Delete(Guid Id)
        {
            _db.ELMAH_Error.DeleteObject(_db.ELMAH_Error.Single(a => a.ErrorId == Id));
            _db.SaveChanges();
        }

        public void DeleteAll()
        {
            foreach (var item in _db.ELMAH_Error)
            {
                _db.ELMAH_Error.DeleteObject(item);

            }
            _db.SaveChanges();
        }
    }
}
